<template>
	<view class="content">
		<MusicList class="block_top favority" :list="data" :showDelete="true" ></MusicList>
		<MusicPlayer ref="player"></MusicPlayer>
	</view>
</template>

<script>
	import MusicPlayer from '../../../component/MusicPlayer/MusicPlayer';
	import MusicList from '../../../component/MusicList/MusicList.vue';
	import favorite from '../../../common/api/favorite/favorite.js';
	export default {
		components: {
			MusicPlayer,
			MusicList
		},
		onShow() {
			this.checkIsLogin();
			this.getMyFavorite();
		},
		created() {
			this.getMyFavorite();
		},
		data() {
			return {
				data:{},
				// 页数
				pageNum: 0,
				// 条数
				pageSize: 20
			}
		},
		methods: {
			// 获取收藏
			getMyFavorite(){
				this.checkIsLogin();
				favorite.list({
					pageNum: this.pageNum,
					pageSize: this.pageSize
				}).then(res=>{
					this.data=res.data.favorite;
				})
			},
			checkIsLogin(){
				return this.$store.getters.isLogin;
			}
		},
		onReachBottom() {
			// 页数+1
			this.pageNum+=1;
			this.getMyFavorite();
		}
	}
</script>

<style>
.favority{
	width: 80%;
	margin-top: 30px;
}
</style>
